package com.ltt.mylibrary.utils;


import android.app.Activity;
import android.content.Context;
import android.content.Intent;

import com.ltt.mylibrary.activity.AllFileActivity;
import com.ltt.mylibrary.activity.LocalFileActivity;

/**
 * @Description: 类作用描述
 * @Author: ltt
 * @CreateDate: 2021/12/27 11:31
 */
public class FileConfig {
    public Builder newBuilder(Activity context) {
        return new Builder(context);
    }

    public static class Builder {
        private Activity context;
        private int defaultCount;
        private int REQUEST_CODE_FILE_CHOOSER = 101;

        public Builder(Activity context) {
            this.context = context;
        }

        /**
         * 设置选择数量
         * @param count 选择数量，默认为5
         * @return
         */
        public Builder setCount(int count) {
            this.defaultCount = count;
            return this;
        }

        /**
         * 回调code，传入自己的
         * @param requestCode
         * @return
         */
        public Builder setRequestCode(int requestCode) {
            this.REQUEST_CODE_FILE_CHOOSER = requestCode;
            return this;
        }

        /**
         * 直接跳转到选择页面
         * @return
         */
        public Builder startActivityForResult() {
            Intent intent = new Intent(context, LocalFileActivity.class);
            intent.putExtra("max", defaultCount);
            context.startActivityForResult(intent, REQUEST_CODE_FILE_CHOOSER);
            return this;
        }

        /**
         * 跳转到可选页面，SD卡、手机、自定义选择器
         * @return
         */
        public Builder startActivityAllForResult() {
            Intent intent = new Intent(context, AllFileActivity.class);
            intent.putExtra("max", defaultCount);
            context.startActivityForResult(intent, REQUEST_CODE_FILE_CHOOSER);
            return this;
        }


    }
}
